import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        int[] fib = new int[10001];
        fib[1] = 1;
        fib[2] = 2;
        for (int i = 3; i < fib.length; i++) {
            fib[i] = fib[i - 1] + fib[i - 2];
            fib[i] %= 10000;
        }
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] nums = new int[n];
            String str = "";
            for (int i = 0; i < n; i++) {
                nums[i] = in.nextInt();
                str = String.format("%04d", fib[nums[i]]);
            }
            System.out.println(str);
        }
    }
}